package org.cmcc.pcap.voltePcapParse.pcap;

/**
 * 协议类型
 * @author starfish
 *
 */
public enum ProtocolType {
	
	OTHER("0","OTHER"), 				// 其他协议号：默认为0
	TCP("6","TCP"), 					// TCP 协议号：6
	UDP("17","UDP"),					// UDP 协议号：17
	ICMP("1","ICMP"),
	IGMP("2","IGMP"),
	IPv4("4","IPv4"),
	IPv6("41","IPv6"),
	GRE("47","GRE"),
	ESP("50","ESP"),
	AH("51","AH"),
	EIGRP("88","EIGRP"),
	OSPF("89","OSPF"),
	PIM("103","PIM"),
	IPX("111","IPX"),
	VRRP("112","VRRP"),
	L2TP("115","L2TP"),
	LSIS("124","LSIS"),
	SCTP("132","SCTP");
	
	private String type;
	
	private String name;
	
	public String getType() {
		return type;
	}
	
	public void setType(String type) {
		this.type = type;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public static ProtocolType getProtocolType(String args){
		for(ProtocolType protocolType : ProtocolType.values()){
			if(protocolType.getType().equals(args)){
				return protocolType;
			}else if(protocolType.getName().equals(args)){
				return protocolType;
			}
		}
		return OTHER;
	}
	
	public static ProtocolType getProtocolType(short type){
		for(ProtocolType protocolType : ProtocolType.values()){
			if(protocolType.getType().equals(Short.toString(type))){
				return protocolType;
			}
		}
		return OTHER;
	}

	private ProtocolType(String type,String name) {
		this.type = type;
		this.name = name;
	}
	
}
